package center.leon.zoogateway.filter.resolver;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author xuxinmin
 */
@Slf4j
@Component(value = "userKeyResolver")
public class UserKeyResolver implements KeyResolver{
    private volatile int lastSec = -1;

    @Override
    public Mono<String> resolve(ServerWebExchange exchange) {
        String key = exchange.getRequest().getQueryParams().getFirst("key");
        log.info("resolve key : {}", key);
        return Mono.just(key);
    }
}